package ch7;

/**
 * @author ANG.YU
 * @date 2020-08-12 11:33
 */
public class Music3 {
    static void tune(Instrument3 i) {
        i.play();
    }

    static void tuneAll(Instrument3[] e) {
        for (Instrument3 i : e) {
            tune(i);
        }
    }

    public static void main(String[] args) {
        Instrument3[] orc = new Instrument3[5];
        int i = 0;
        orc[i++] = new Wind3();
        orc[i++] = new Percussion3();
        orc[i++] = new Percussion3();
        orc[i++] = new Brass3();
        orc[i++] = new Woodwind3();
        tuneAll(orc);
    }
}

class Instrument3 {
    public void play() {
        System.out.println("Instrument3.play()");
    }

    public String what() {
        return "Instrument3";
    }

    public void adjust() {

    }
}

class Wind3 extends Instrument3 {
    @Override
    public void play() {
        System.out.println("Wind3.play()");
    }

    @Override
    public String what() {
        return "Wind3";
    }

    @Override
    public void adjust() {
    }
}

class Percussion3 extends Instrument3 {
    @Override
    public void play() {
        System.out.println("Percussion.play()");
    }

    @Override
    public String what() {
        return "Percussion3";
    }

    @Override
    public void adjust() {
    }
}

class Stringed3 extends Instrument3 {
    @Override
    public void play() {
        System.out.println("Stringed3.play()");
    }

    @Override
    public String what() {
        return "Stringed3";
    }

    @Override
    public void adjust() {
    }
}

class Brass3 extends Wind3 {
    @Override
    public void play() {
        System.out.println("Brass3.play()");
    }

    @Override
    public void adjust() {
        System.out.println("Brass3.adjust()");
    }
}

class Woodwind3 extends Wind3 {
    @Override
    public void play() {
        System.out.println("Woodwind3.play()");
    }

    @Override
    public String what() {
        return "Woodwind3";
    }
}
